package JXY01;

import java.awt.image.BufferedImage;

public abstract class FlyingObject {
    protected int x;
    protected int y;
    protected BufferedImage image;
    protected int speed;
    protected int width;
    protected int height;

    public abstract void move();

    //判断当前飞行物有没有被指定子弹撞击
    public boolean shootBy(Bullet bullet){
        int x = bullet.getX();
        int y = bullet.getY();
        return this.x < x && x < this.width + this.x
                && this.y < y && y < this.y + this.height;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public BufferedImage getImage() {
        return image;
    }

    public void setImage(BufferedImage image) {
        this.image = image;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }
    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {this.height = height;}
    public int getWidth() {
        return width;
    }

    public void setWidth(int height) {this.width = width;}
}
